package Hilfsklassen;

import java.awt.Color;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.WindowStateListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.LineBorder;

public class MainView extends HintergrundPanel {

	public MainView()
	{	
	
			this.setHintergrundBild("kachelo.png");

			int hoehe = 1000;
			int breite = 730;
			this.setSize(hoehe, breite);
			this.setLayout(null);
			this.setBorder(new LineBorder(Color.BLACK, 4));
		
		
		// Ausmasse der Karten
		int icW = 100;
		int icH = 150;
		int horGap = 3;
		int verGap = 20;
		
		
		for(int i = 1; i < 3; i++)
		{
			JPanel spielerBoard = new JPanel();	
			spielerBoard.setBackground(new Color(0, 0, 0, 50));
			spielerBoard.setSize(7 * (icW + horGap), icH + 40 );
			spielerBoard.setLocation(breite- spielerBoard.getWidth() , (i-1)  * (icH + verGap + 40) +80);
//			spielerBoard.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1, true));
			spielerBoard.setLayout(new FlowLayout(FlowLayout.RIGHT));
			spielerBoard.add(new JLabel("Spieler " + i));
			add(spielerBoard);
			
			
			for(int it = 1; it < 7; it++)
			{
				//				String farbe = farbeVonZahl(it);
//				JButton j = new JButton();
//				j.setIconTextGap(0);
//				j.setSize(100, 150);
//				j.setMargin(new Insets(0,0,0,0));
				
//				GUIKarte j = new GUIKarte(farbe);
//				JLabel j = new JLabel();
				KartenButton j = new KartenButton(farbeVonZahl(it), "0", icH, true);
//				j.setName("s" + i + farbe);
//				j.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().getImage("Images/" + farbeVonZahl(it) + ".png").getScaledInstance(icW, icH, Image.SCALE_SMOOTH)));
//				j.setText(j.getName());								// Ausblendbar, einfach wegmachen!
//				j.setHorizontalTextPosition(SwingConstants.CENTER);
//				j.setVerticalTextPosition(SwingConstants.TOP);
				spielerBoard.add(j);				
			}		
			
		}

		JButton button2 = new JButton("omfg");
		button2.setSize(100, 100);
		add(button2);
		
		JButton senden = new JButton("Senden");
		senden.setSize(100, 50);
		senden.setLocation(breite-senden.getWidth(), hoehe-senden.getHeight());
		add(senden);
		
		
		
		JButton button = new JButton("jajaja");
		button.setSize(100, 100);
		add(button);
		
		
		JTextField chatArea = new JTextField();
		chatArea.setSize(600, 50);
		chatArea.setFont(new Font("Arial", Font.PLAIN, 21));
		chatArea.setLocation(breite-chatArea.getWidth()-senden.getWidth(), hoehe-chatArea.getHeight());
		add(chatArea);
		
		JButton closeButton = new JButton("Schliessen");
		closeButton.setSize(100, 40);
		closeButton.setLocation(breite-closeButton.getWidth(), 0);
		closeButton.setVisible(true);
		this.setVisible(true);
//		this.add(closeButton);		
		}
	
	
	
	public static String farbeVonZahl(int i)
	{
		String farbe ="";
		switch(i)
		{
			case 1: farbe = "d"; break;
			case 2: farbe = "g"; break;
			case 3: farbe = "r"; break;
			case 4: farbe = "t"; break;
			case 5: farbe = "v"; break;
			case 6: farbe = "z"; break;
			case 7: farbe = "j"; break;
			case 8: farbe = "p"; break;
		}
		return farbe;
	}
	

}